//package com.zhs.gccs.utils;
//
//import com.aspose.cad.CodePages;
//import com.aspose.cad.Color;
//import com.aspose.cad.Image;
//import com.aspose.cad.LoadOptions;
//import com.aspose.cad.imageoptions.CadRasterizationOptions;
//import com.aspose.cad.imageoptions.JpegOptions;
//import com.aspose.cad.imageoptions.PdfOptions;
//
//import java.io.File;
//import java.io.FileOutputStream;
//import java.io.IOException;
//import java.io.OutputStream;
//import java.util.Locale;
//
//public class CadUtils {
////    https://blog.csdn.net/weixin_42476367/article/details/123047070
//    /**
//     *方法描述  CAD文件转换为PDF流
//     * @param srcFile 选择CAD文件路径
//     * @param dataDir 保存pdf文件路径
//     */
//    public static void cadToPdf1(String srcFile,String dataDir){
//        Image objImage = Image.load(srcFile);
//        CadRasterizationOptions cadRasterizationOptions = new CadRasterizationOptions();
//        cadRasterizationOptions.setBackgroundColor(Color.getWhite());
//        cadRasterizationOptions.setPageWidth(1920);
//        cadRasterizationOptions.setPageHeight(1080);
//        PdfOptions pdfOptions = new PdfOptions();
//        pdfOptions.setVectorRasterizationOptions(cadRasterizationOptions);
//        objImage.save(dataDir, pdfOptions);
//        objImage.close();
//    }
//    public static void cadToImage(String srcFile,String destFile){
//        CadRasterizationOptions cadRasterizationOptions = new CadRasterizationOptions();
//        cadRasterizationOptions.setBackgroundColor(Color.getWhite());
//        cadRasterizationOptions.setPageWidth(1920);
//        cadRasterizationOptions.setPageHeight(1080);
//        cadRasterizationOptions.setDrawColor(Color.getBlack());
//        JpegOptions jpegOptions = new JpegOptions();
//        jpegOptions.setVectorRasterizationOptions(cadRasterizationOptions);
//        Image objImage = Image.load(srcFile);
//        objImage.save(destFile, jpegOptions);
//        objImage.close();
//    }
//    public static boolean cadToPdf(String inputFilePath, String outputFilePath)  throws Exception  {
//        File outputFile = new File(outputFilePath);
//        //添加中午支持
//        Locale locale = new Locale("zh", "cn");
//        Locale.setDefault(locale);
//        LoadOptions opts = new LoadOptions();
//        opts.setSpecifiedEncoding(CodePages.SimpChinese);
//        Image cadImage = Image.load(inputFilePath, opts);
//        CadRasterizationOptions cadRasterizationOptions = new CadRasterizationOptions();
//        cadRasterizationOptions.setBackgroundColor(Color.getWhite());
//        cadRasterizationOptions.setPageWidth(1400);
//        cadRasterizationOptions.setPageHeight(650);
//        cadRasterizationOptions.setAutomaticLayoutsScaling(true);
//        cadRasterizationOptions.setNoScaling(false);
//        cadRasterizationOptions.setDrawType(1);
//        PdfOptions pdfOptions = new PdfOptions();
//        pdfOptions.setVectorRasterizationOptions(cadRasterizationOptions);
//        OutputStream stream = null;
//        try {
//            stream = new FileOutputStream(outputFile);
//            cadImage.save(stream, pdfOptions);
//        } catch (IOException e) {
////                logger.error("PDFFileNotFoundException，inputFilePath：{}", inputFilePath, e);
//            return false;
//        } finally {
//            if (stream != null) {   //关闭
//                stream.close();
//            }
//            if (cadImage != null) {   //关闭
//                cadImage.close();
//            }
//        }
//        return true;
//    }
//}
